package com.situ.mall.common.mapper;

import com.situ.mall.common.entity.Product;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.common.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lwj
 * @since 2023-09-12
 */
public interface ProductMapper extends BaseMapper<Product> {

    List<ProductVO> listProduct(@Param("name") String name, @Param("status") String status);

    void delete(String[] split);

    @Select("select product.*,category.parent_id 'topCategory' from product inner join category on product.category_id = category.id where product.id=#{id}")
    EditProductVO edit(Integer id);

    @Select("select * from product where category_id = #{id} and status = '1' order by price limit 0,1")
    IndexProductVO selecProduct(Integer id );


    List<IntroductionProductVO> selectIntroductionProduct(Integer id);

    @Select("select * from product where instr(name,#{keyword})>0")
    List<IndexProductVO> searchList(String keyword);

}
